home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 1
/
Precision Software Applications Silver Collection Volume One (PSM) (1993).iso
/
tutor
/
ada1tutr.arj
/
FIBTEST.ADA
< prev
next >
Wrap
Text File
|
1992-09-04
|
912b
|
32 lines
with TEXT_IO; use TEXT_IO;
procedure FIBTEST is
PASSED : BOOLEAN := TRUE;
function FIB(N : in POSITIVE) return POSITIVE is separate;
procedure COMPARE (N : in POSITIVE; RIGHT_ANSWER : in POSITIVE) is
package INT_IO is new INTEGER_IO(INTEGER); use INT_IO;
MY_ANSWER : POSITIVE := FIB(N);
begin
if MY_ANSWER /= RIGHT_ANSWER then
PUT("N:"); PUT(N);
PUT(" My answer:"); PUT(MY_ANSWER);
PUT(" Right answer:"); PUT(RIGHT_ANSWER);
NEW_LINE;
PASSED := FALSE;
end if;
end COMPARE;
begin
COMPARE(1, 1);
COMPARE(2, 1);
COMPARE(3, 2);
COMPARE(4, 3);
COMPARE(5, 5);
COMPARE(6, 8);
COMPARE(7, 13);
COMPARE(10, 55);
COMPARE(15, 610);
COMPARE(20, 6765);
if PASSED then
PUT_LINE("Congratulations, you completed the assignment!");
end if;
end FIBTEST;